<?=$this->headTitle('information');?>
<script type="text/javascript">
$(function(){

    $.post('/admin/siteinfo',{data:'userinfo'},function(resp){
       if(resp){
           var usercont = $('#user-container');
           var artcont = $('#art-container');
           var commcont = $('#comminfo-container');
           var catcont = $('#catinfo-container');
           var userscont = $('#usersinfo-container');
           var logTime = new Date(resp.logindatetime);
           var lastLog = new Date(resp.lastlogintime);

           usercont.find('#userip').append(resp.userip);
           usercont.find('#username').append(resp.userlogin).end().find('#userrole').append(resp.role).end()
               .find('#logintime').append(logTime.toLocaleString());

           if(resp.lastlogintime != resp.logindatetime && lastLog < logTime){

                   usercont.find('#lastlogintime').append(lastLog.toLocaleString());
           }else{
               usercont.find('#lastlogintime').closest('tr').hide();
           }
           artcont.find('#artcount').append(resp.artcount || 0).end().find('#artpub').append(resp.artvisibyes || 0).end()
               .find('#artnotpub').append(resp.artvisibno || 0);

           commcont.find('#commentscount').append(resp.commentscount || 0).end().find('#commentsvisibyes').append(resp.commentsvisibyes || 0).end()
               .find('#commentsvisibno').append(resp.commentsvisibno || 0);
           catcont.find('#categorycount').append(resp.categoriescount || 0);
           userscont.find('#userscount').append(resp.userscount || 0);
       }
        setTimeout(getLastResource,1000);
    });
    function getLastResource(){
        $.get('/admin/index/getlastresource',{},function(resp){
            var resinfo = $('#resourceinfo-container tbody tr');
            if(resp.oper !='failed'){
                var max = resp.length;
               for(var i=0;i < max;i+=1){
                   $(resinfo[i]).find('td:first').text(resp[i].article_id).next().text(resp[i].page).next().text(resp[i].created_dt);
               }
            }else{
                var resInfo = $('#resourceinfo-container tbody');
                resInfo.find('tr').hide();
                resInfo.find('tr:first').show().find('td:first').text('Ресурсов не обнаружено');
            }
        });
    }
});
</script>
<div id="maincontainer" style="float:left;width:800px;">
   <div style = "padding-left:40px;color:#555555"><h5></h5></div>
<div id="art-container" class="ui-widget" style="float:left;padding-left:40px;">
    <table id = "artinfo" class="ui-widget ui-widget-content">
        <thead>
        <tr class="ui-widget-header">
            <th colspan="2">Статьи</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>Всего статей</td><td id = "artcount"></td>
        </tr>
        <tr>
            <td>Опубликованных</td> <td  id = "artpub"></td>
        </tr>
        <tr>
            <td>Не опубликованных</td><td id = "artnotpub"></td>
        </tr>
        </tbody>
    </table>
</div>

<div id="comminfo-container" class="ui-widget" style="float:right;">
    <table id = "comminfo" class="ui-widget ui-widget-content"">
        <thead>
        <tr class="ui-widget-header">
            <th colspan="2">Комментарии</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>Всего комментариев</td><td id = "commentscount"></td>
        </tr>
        <tr>
            <td>Опубликованных</td><td id = "commentsvisibyes"></td>
        </tr>
        <tr>
            <td>Ждущих одобрения</td><td id = "commentsvisibno"></td>
        </tr>
        </tbody>
    </table>
</div>
<div id="catinfo-container" class="ui-widget" style="float:left;padding-left:40px;">
    <table id = "catinfo" class="ui-widget ui-widget-content"">
        <thead>
        <tr class="ui-widget-header">
            <th colspan="2">Категории</th>

        </tr>
        </thead>
        <tbody>
        <tr>
            <td>Всего категорий</td><td id = "categorycount"></td>
        </tr>

        </tbody>
    </table>
</div>

<div id="usersinfo-container" class="ui-widget" style="float:right">
    <table id = "userinfo" class="ui-widget ui-widget-content"">
    <thead>
    <tr class="ui-widget-header">
        <th colspan="2">Пользователи</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td>Всего зарегистрированных пользователей</td>
        <td id = "userscount"></td>
    </tr>
    <!--  <tr>
          <td></td>
          <td></td>
      </tr>
      <tr>
          <td></td>
          <td></td>
      </tr> -->
    </tbody>
    </table>
</div>
</div>
<div id="secondary-container" style="width:800px;float:left;padding:10px 0 0 40px;">
    <div id="resourceinfo-container" class="ui-widget" style="float:left;padding-right:40px;">
        <table id = "resourceinfo-container" class="ui-widget ui-widget-content"">
        <thead>
        <tr class="ui-widget-header">
            <th colspan="3">Недавно созданные/отредактированные ресурсы</th>
        </tr>
        <tr>
            <th  style="border:1px solid #3399ff"><strong>ID-ресурса</strong></th>
            <th  style="border:1px solid #3399ff"><strong>Страница</strong></th>
            <th  style="border:1px solid #3399ff"><strong>Дата создания/Изменения</strong></th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        </tbody>
        </table>
    </div>

<div id="user-container" class="ui-widget" style="float:left">
    <table id = "user" class="ui-widget ui-widget-content" style="width:300px;">
    <thead>
    <tr class="ui-widget-header">
        <th colspan="2">Онлайн</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td>Вы авторизованы как:</td>
        <td id = "username" style = "font-weight:bold;"></td>
    </tr>
    <tr>
        <td>Ваша роль:</td>
        <td id = "userrole" style = "font-weight:bold;"></td>
    </tr>
    <tr>
        <td>Ваш IP-адрес:</td>
        <td id="userip"></td>
    </tr>
    <tr>
        <td>Вход произведен:</td>
        <td id="logintime"></td>
    </tr>
    <tr>
        <td>Последняя авторизация:</td>
        <td id = "lastlogintime"></td>
    </tr>
    </tbody>
    </table>
</div>
</div>
</div>
</div>